from src import Node_raw_data

class Device_HeartBeat():
    def __init__(self):
        self.heartbeat_num = {}
        self.ready = {}
        for pvname,host in Node_raw_data.items():
            self.heartbeat_num[host] = 0
            self.ready[host] = 0
    def clear_heartbeat(self):
        for host in self.heartbeat_num.keys():
            self.heartbeat_num[host] = 0
    def ready_signal(self,host,ready):
        if host in self.ready.keys() and host in self.heartbeat_num.keys():
            self.ready[host] = ready
            self.heartbeat_num[host] += 1

device_heartbeat = Device_HeartBeat()